const NORMAL_ORDER_TYPE = ['GH', 'ZX', 'DZ', 'SH', 'WT', 'TW', 'DH', 'TD', 'XZ', 'TS', 'KS', 'FX', 'dh'];
const VIP_ORDER_TYPE = ['HY', 'hy'];
const TOPUP_ORDER_TYPE = ['CZ', 'cz'];




function getMixinByOrderType() {
	return {
		methods: {
			async getOrderList(status) {
				console.log('status>>>>>>>>>>>>>>>>>', status)
				switch (this.orderType) {
					case 'hy':
						this.restUrl = this.$restUrl.getOrderListVip;
						this.detailRestUrl = this.$restUrl.getOrderDetailVip;
						break;
					case 'HY':
						this.restUrl = this.$restUrl.getOrderListVip;
						this.detailRestUrl = this.$restUrl.getOrderDetailVip;
						break;
					case 'KS':
						this.restUrl = this.$restUrl.getOrderListQuickly;
						this.detailRestUrl = this.$restUrl.getOrderDetailQuickly;
						break;
					case 'CZ':
						this.restUrl = this.$restUrl.getOrderListTopup;
						this.detailRestUrl = this.$restUrl.getOrderDetailTopup;
						break;
					case 'cz':
						this.restUrl = this.$restUrl.getOrderListTopup;
						this.detailRestUrl = this.$restUrl.getOrderDetailTopup;
						break;
					case 'DH':
						this.restUrl = this.$restUrl.getOrderListMobile;
						this.detailRestUrl = this.$restUrl.getOrderDetailMobile;
						break;
					case 'dh':
						this.restUrl = this.$restUrl.getOrderListMobile;
						this.detailRestUrl = this.$restUrl.getOrderDetailMobile;
						break;
					case 'FX':
						this.restUrl = this.$restUrl.getOrderListAnalysis;
						this.detailRestUrl = this.$restUrl.getOrderDetailAnalysis;
						break;
				}
				if (this.status == 'loading') {
					return
				}
				this.status = 'loading';
				let options
				if (!!status) {
					options = {
						order_status: status,
						page: this.pageNum,
						page_num: this.pageSize,
					}
				} else {
					options = {
						page: this.pageNum,
						page_num: this.pageSize,
					}
				}
				const {
					data
				} = await this.$u.post(this.restUrl, options)
				this.status = data.data.length ? 'loadmore' : 'nomore';
				this.pageNum++;
				console.log(data);
				this.orderList.push(...data.data);
				console.log('this.orderList>>>>>>>>>>>>>>>>>>>>>>>>>>>', this.orderList);
			}
		},
		computed: {
			orderView() {
				if (!this.orderType) {
					return
				}
				switch (this.orderType) {
					case 'hy':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/c4f8f783-47b7-406e-b898-0ee3822dbdf7.png',
								title: '年费会员',
								navbar:'会员工单',
						}
						break;
					case 'HY':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/c4f8f783-47b7-406e-b898-0ee3822dbdf7.png',
								title: '年费会员',
								navbar:'会员工单',
						}
						break;
					case 'KS':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/c1ec57c4-2fad-469e-afd6-78af94873dd6.png',
								title: '快速咨询',
								navbar:'快速咨询工单',
						}
						break;
					case 'CZ':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/d57056f0-c606-4608-8a16-d7b25767a3c2.png',
								title: '余额充值',
								navbar:'余额充值工单',
						}
						break;
					case 'cz':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/d57056f0-c606-4608-8a16-d7b25767a3c2.png',
								title: '余额充值',
								navbar:'余额充值工单',
						}
						break;
					case 'DH':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/25ffcda2-dc3c-44b5-b99c-ba1762b90a0d.png',
								title: '电话咨询',
								navbar:'电话咨询工单',
						}
						break;
					case 'dh':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/25ffcda2-dc3c-44b5-b99c-ba1762b90a0d.png',
								title: '电话咨询',
								navbar:'电话咨询工单',
						}
						break;
					case 'FX':
						return {
							icon:
								'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/bde87b66-3fe0-49db-9f43-1e61b117b14f.png',
								title: '案件分析',
								navbar:'案件分析工单',
						}
						break;
				}
			},
			tabList() {
				if (!this.orderType) {
					return
				} else if (VIP_ORDER_TYPE.indexOf(this.orderType) != -1) {
					return [
						// 	{
						// 	name: '全部订单',
						// }, 
						{
							name: '待支付',
							status: 1,
						}, {
							name: '已支付',
							status: 2,
						}
					]
				} else if (NORMAL_ORDER_TYPE.indexOf(this.orderType) != -1) {
					return [
						// 	{
						// 	name: '全部订单',
						// }, 
						{
							name: '待支付',
							status: 1,
						}, {
							name: '待处理',
							status: 2,
						}, {
							name: '进行中',
							status: 3,
						}, {
							name: '已完成',
							status: 4,
						}
					]
				} else if (TOPUP_ORDER_TYPE.indexOf(this.orderType) != -1) {
					return [
						// 	{
						// 	name: '全部订单',
						// }, 
						{
							name: '待支付',
							status: 1,
						}, {
							name: '已完成',
							status: 2,
						}, {
							name: '已取消',
							status: 3,
						}
					]
				}
			},
			payStatus() {
				return (order) => {
					if (!this.orderType) {
						return
					} else if (VIP_ORDER_TYPE.indexOf(this.orderType) != -1) {
						if (order.pay_status == 1) {
							return {
								orderStyle: 'paying',
								orderBtnText: '立即支付',
								orderTitle: '待支付',
								orderBtnClick: this.payAgain
							}
						} else if (order.pay_status == 2) {
							return {
								orderStyle: 'complate',
								orderBtnText: '查看详情',
								orderTitle: '已支付',
								orderBtnClick: this.toDetail
							}
						} else if (order.pay_status == 3) {
							return {
								orderStyle: 'overdue',
								orderBtnText: '开通会员',
								orderTitle: '已过期',
								orderBtnClick: this.renewal
							}
						} else if (order.pay_status == 4) {
							return {
								orderStyle: 'cancel',
								orderBtnText: '重新下单',
								orderTitle: '已取消',
								orderBtnClick: this.renewal
							}
						}
					} else if (NORMAL_ORDER_TYPE.indexOf(this.orderType) != -1) {
						if (order.pay_status == 1) {
							return {
								orderStyle: 'paying',
								orderBtnText: '立即支付',
								orderTitle: '待支付',
								orderBtnClick: this.payAgain
							}
						} else if (order.pay_status == 2 || order.pay_status == 4) {
							if (order.status == 1) {
								return {
									orderStyle: 'pending',
									orderBtnText: '查看详情',
									orderTitle: '待处理',
									orderBtnClick: this.toDetail
								}
							} else if (order.status == 2) {
								return {
									orderStyle: 'pending',
									orderBtnText: this.orderType == 'KS' ? '继续咨询' : '查看详情',
									orderTitle: '进行中',
									orderBtnClick: this.orderType == 'KS' ? this.toConsult : this.toDetail
								}
							} else if (order.status == 3) {
								return {
									orderStyle: 'complate',
									orderBtnText: '立即评价',
									orderTitle: '已完成',
									orderBtnClick: this.toEvaluation
								}
							}
						} else if (order.pay_status == 3) {
							return {
								orderStyle:'cancel',
								orderBtnText:'查看详情',
								orderTitle:'已取消',
								orderBtnClick: this.toDetail
							}
						}
					} else if (TOPUP_ORDER_TYPE.indexOf(this.orderType) != -1) {
						if (order.pay_status == 1) {
							return {
								orderStyle: 'paying',
								orderBtnText: '立即支付',
								orderTitle: '待支付',
								orderBtnClick: this.topupAgain
							}
						} else if (order.pay_status == 2) {
							return {
								orderStyle: 'complate',
								orderBtnText: '查看详情',
								orderTitle: '已支付',
								orderBtnClick: this.toDetail
							}
						} else if (order.pay_status == 3) {
							return {
								orderStyle: 'cancel',
								orderBtnText: '重新充值',
								orderTitle: '已取消',
								orderBtnClick: this.toTopup
							}
						}
					}
				}
			}
		}
	}
}
export {
	getMixinByOrderType
}
